<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="${staticServer}/inc/style/main.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/page.css" />
<link rel="stylesheet" href="${staticServer}/css/work_today.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_client_tracking.css" />
<link rel="stylesheet" href="${staticServer}/inc/style/date/datepicker.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_client.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_client_tracking.css" />
<link rel="stylesheet" href="${staticServer}/css/consultant_student_read.css" />
<script src="${staticServer}/inc/js/jquery.js"></script>
<script src="${staticServer}/inc/js/pageset.js"></script>
<script src="${staticServer}/inc/js/model_resp.js"></script>
<script src="${staticServer}/inc/js/datepicker.js"></script>
<script src="${staticServer}/inc/js/htmlfilter.js"></script>
<script src="${staticServer}/inc/js/submitter.js"></script>
<script src="${staticServer}/inc/js/tips.js"></script>
<style type="text/css">
#statelist label {
	display: block;
	float: left;
	width: 120px;
}
</style>
<script>
//老师的ids 和 names
var teachers = "";
 
$(function(){
	$("#type").val("${type}");
	$("#state").val("<#if clientImp??>${clientImp.state}</#if>");
	$("#phone").val("<#if clientImp??>${clientImp.phone}</#if>");
	$("#lianxi_name").val("<#if clientImp??>${clientImp.lianxi_name}</#if>");
	$("#color").val("<#if clientImp??>${clientImp.color}</#if>");
	$("#st_type").val("<#if clientImp??>${clientImp.st_type}</#if>");
	
	$("#state1").val("${state1}");
});
/**
* 批量分配
*/
function plfp(){
	//获取复选框
	var r = document.getElementsByName("ids");  
    for(var i=0;i<r.length;i++){
         if(r[i].checked){
         	teachers += r[i].value +",";
         }
    } 
    if(teachers == ""){
    	alert("您还未选中数据！");
    	return false;
    }
    window.location.href="${contextPath}/network/sczy_plfp.htm?ids="+teachers;
}

$(function(){
	//全选按钮 
	$("#allChecked").click(function(){
		if($(this).is(':checked')==true){
			$("#datas td input[type=checkbox]").prop("checked","true");
		}else{
			$("#datas td input[type=checkbox]").prop("checked",false);
		}
	});

});

var deleteClient = function(){
	var $obj = $("#datas td input[type=checkbox]:checked");
	if($obj.length == 0){
		alert("请至少选择一条记录");
		return ;
	}
	if(confirm("确定删除？删除后无法恢复。")){
		var ids = '';
		for(var i = 0;i<$obj.length;i++){
			if(i == $obj.length-1){
				ids += $($obj[i]).val();
			}else{
				ids += $($obj[i]).val()+",";
			}
		}
		var url = "${contextPath}/consu/consultant_delete.json";
    	$.post(url, {"ids":ids}, 
			function(ms) {
	 			if(ms.msg != null){
	 				if(ms.msg == "0"){
	 					alert("不是自己的资源，无法删除！");
	 				}else if(ms.msg == "1"){
	 					alert("删除成功!");
	 					setTimeout(function(){
	 						location.reload(); 
						},1200);
	 				}else if(ms.msg == "2"){
	 					alert("已分配资源不可删除!");
	 				}
	 				
	 			}else{
	 				alert("抱歉，系统忙");
	 			}
    	});
    };
}

var updateClient = function(){
	var $obj = $("#datas td input[type=checkbox]:checked");
	if($obj.length == 0){
		alert("请至少选择一条记录");
		return ;
	}
	if(confirm("确定标记？标记后无法恢复。")){
		var ids = '';
		for(var i = 0;i<$obj.length;i++){
			if(i == $obj.length-1){
				ids += $($obj[i]).val();
			}else{
				ids += $($obj[i]).val()+",";
			}
		}
		var url = "${contextPath}/consu/consultant_update.json";
    	$.post(url, {"ids":ids}, 
			function(ms) {
	 			if(ms.msg != null){
	 				if(ms.msg == "0"){
	 					alert("不是自己的资源，无法标记！");
	 				}else if(ms.msg == "1"){
	 					alert("标记成功!");
	 					setTimeout(function(){
	 						location.reload(); 
						},1200);
	 				}else if(ms.msg == "2"){
	 					alert("已分配资源不可标记!");
	 				}
	 				
	 			}else{
	 				alert("抱歉，系统忙");
	 			}
    	});
    };
}

var czhi = function(){
	$("#type").val("");
	$("#state").val("");
	$("#color").val("");
	$("#st_type").val("");
	$("#lianxi_name").val("");
	$("#phone").val("");
	window.location.href="${contextPath}/network/sczy_allot_list.htm?haiQx=${haiQx}";
}

function state(stat){
	window.location.href="${contextPath}/network/sczy_allot_list.htm?stat="+stat+"&haiQx=${haiQx}";
}

function submit(){
	window.location.href="${contextPath}/network/sczy_allot_list.htm?type="+$("#type").val()+"&lianxi_name="+$("#lianxi_name").val()+"&phone="+$("#phone").val()+"&state="+$("#state").val()+"&color="+$("#color").val()+"&st_type="+$("#st_type").val()+"&stardate="+$("#stardate").val()+"&enddate="+$("#enddate").val()+"&haiQx=${haiQx}";
}
</script>
</head>

<body>
<input type="hidden" id="keyname" value="">
<input type="hidden" id="traId" value="">
	<div id="home_link">
		<ul>
			<li></li>
			<li>&gt;</li>
			<li>资源统计管理</li>
			<li>&gt;</li>
			<li class="current">市场部资源</li>
		</ul>
	</div>
	<div id="container">
		<div id="title">红色表示重复资源，紫色表示无效资源，蓝色表示重复加无效资源。</div>
		<table class="form_table">
			<tr>
				<td>
					<div style="overflow: hidden;">
						<label><b>查询条件：</b></label>
						<select id="type">
							<option value="">类型不限</option>
							<#if type2??>
								<#list type2?split(",") as name>
									<#if name?? && name!="">
										<option value="${name}"><#if name=="lixianbao">离线宝<#elseif name=="02FAC12A4746">百度糯米团购<#elseif name=="frvmppoifgmb">今日头条广告</#if></option>
									</#if>
								</#list>
							<#else>
								<#if sourcelist??>
									<#list sourcelist as list>
										<#if list.keyname!="lixianbao"  && list.keyname!="frvmppoifgmb">
										<option value="${list.keyname}">${list.name}</option>
										</#if>
									</#list>
								</#if>
							</#if>
						</select>
						
						<select id="state">
							<option value="">状态不限</option>
							<option value="0">未分配</option>
							<option value="1">已分配</option>
						</select>
						<select id="color">
							<option value="">全部资源</option>
							<option value="1">重复资源</option>
						</select>
						<select id="st_type">
							<option value="">全部资源</option>
							<option value="1">有效资源</option>
							<option value="2">无效资源</option>
						</select>
						<input type="text" id="lianxi_name" size="10" value="" placeholder="客户姓名" /> 
						<input type="text" id="phone" size="12" value="" placeholder="电话/QQ" /><br/><br/>
						<input style="margin-left:70px;" type="text" id="stardate" size="13" rel="DATE::Y-m-d" value="${stardate}" readonly="readonly" class="DatePicker_Icon">
						<input type="text" id="enddate" size="13" rel="DATE::Y-m-d" value="${enddate}" readonly="readonly" class="DatePicker_Icon">
						<input type="button" value=" 查 询 " onclick="submit()" />
						<#if webutil.getCookieUser().usergroup!=9>
							<input title="清理自己填写或上传的错误数据" type="button" value=" 删除 " onclick="deleteClient()" />
						</#if>
						<input type="button" value=" 重置 " onclick="czhi()" />
						<input type="button" value=" 标记无效 " onclick="updateClient()" />
						<input type="button" value=" 批量分配 " onclick="plfp()" />
						
					</div>
				</td>
			</tr>
		</table>
		<table>
			<tr class="fields">
				<th><input name="" type="checkbox" value="" id="allChecked"></th>
				<th>登记<br/>老师</th>
				<th>状态</th>
				<th>客户<br/>姓名</th>
				<th>电话/QQ</th>
				<th>城市</th>
				<th>渠道</th>
				<th>活动分类</th>
				<th>推广<br/>老师</th>
				<th>获取资源日期</th>
				<th>上传日期</th>
				<th>操作</th>
			</tr>
			
			<tbody id="datas">
			<#if list??>
				<#list list as list>
					<tr class="even_row" <#if list.color=="1" && list.st_type=="2">style="color:#30A8CF;"<#elseif list.color=="1">style="color:red;"<#elseif list.st_type=="2">style="color:#A65BC1;"</#if>>
						<td align="center">
							<#if list.state != "2">
								<input name="ids" type="checkbox" value="${list.id}">
							</#if>
						</td>
						<td align="center" name="teacherName">${list.nickname}</td>
						<td align="center"><#if list.state=="1"><span class="stress">${list.to_nickname}</span><#else>未分配</#if></td>
						<td align="center">${list.lianxi_name}</td>
						<td align="center"><#if list.phone?? && list.phone!="">${list.phone?replace(".00","")}/</#if><#if list.qq?? && list.qq!="">${list.qq?replace(".00","")}</#if></td>
						<td align="center">
						<#if list.city?? || list.city!="">
							${list.city}
						<#else>
							${list.province}&nbsp;${list.province_city}
						</#if>
						</td>
						<td align="center">${list.sourcens}</td>
						<td align="center">${list.activtity_class}</td>
						<td align="center">${list.tui_nickname}</td>
						<td align="center"><#if list.jl_time??>${list.jl_time?string("yyyy-MM-dd HH:mm:ss")}</#if></td>
						<td align="center"><#if list.create_time??>${list.create_time?string("yyyy-MM-dd HH:mm:ss")}</#if></td>
						
						<td align="center">
						<a href="${contextPath}/consu/consultant_import_allot.htm?id=${list.id}&currPage=${currPage}" >分配</a>
						</td>
						
					</tr>
	            <tr id="__TRACKING_LIST${list.id}" style="display:none">
	            	<td colspan="10" class="trackinglst" id="trackList${list.id}">
	            	</td>
	            </tr>
				</#list>
			</#if>
			</tbody>
		</table>
	</div>
	<div id="pager" style="width: 820px;">
	<ul id="pagination">
		<#if page??>
		<#if page.pagetotal?? && page.pagetotal!="0">
	<#assign pagetotal = page.pagetotal>
	<#else>
	<#assign pagetotal = 1>
	</#if>
			<#if page.currpage??>
	<#assign currpage = page.currpage>
	<#else>
	<#assign currpage = 1>
	</#if>
				<#if currpage==1 >
					<li class="previous-off">上一页</li>
					<#else>
					<li class="previous"><a href="${contextPath}/network/sczy_allot_list.htm?currPage=${currpage-1}&type=${clientImp.type}&state=${clientImp.state}&color=${clientImp.color}&st_type=${clientImp.st_type}&stat=${state1}&stardate=${stardate}&enddate=${enddate}&haiQx=${haiQx}">上一页</a></li>
					</#if>
					
		<#if pagetotal<=11>
			<#list 1..pagetotal as index_up>  
	           <#if currpage==index_up > 
	           		<li class="current">${index_up}</li>
	           <#else>
	           		<li><a href="${contextPath}/network/sczy_allot_list.htm?currPage=${index_up}&type=${clientImp.type}&state=${clientImp.state}&color=${clientImp.color}&st_type=${clientImp.st_type}&stat=${state1}&stardate=${stardate}&enddate=${enddate}&haiQx=${haiQx}">${index_up}</a></li>  
	           </#if>  
			</#list>  
		<#else>
			<#if currpage<=8 >
				<#list 1..9 as index_up>  
	           	<#if currpage==index_up >  
	            	<li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/network/sczy_allot_list.htm?currPage=${index_up}&type=${clientImp.type}&state=${clientImp.state}&color=${clientImp.color}&st_type=${clientImp.st_type}&stat=${state1}&stardate=${stardate}&enddate=${enddate}&haiQx=${haiQx}">${index_up}</a></li> 
	           	</#if>
	           	</#list>  
	           	<li>...</li>
	           	<li><a href="${contextPath}/network/sczy_allot_list.htm?currPage=${pagetotal}&type=${clientImp.type}&state=${clientImp.state}&color=${clientImp.color}&st_type=${clientImp.st_type}&stat=${state1}&stardate=${stardate}&enddate=${enddate}&haiQx=${haiQx}">${pagetotal}</a></li>  
				
			<#elseif (currpage>= 9 && currpage<pagetotal-7)  >	
				<li><a href="${contextPath}/network/sczy_allot_list.htm?currPage=1&type=${clientImp.type}&state=${clientImp.state}&color=${clientImp.color}&st_type=${clientImp.st_type}&stat=${state1}&stardate=${stardate}&enddate=${enddate}&haiQx=${haiQx}">1</a></li>  
				<li>...</li>
				<#list currpage-3..currpage+3 as index_up>  
	           	<#if currpage==index_up >  
	             <li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/network/sczy_allot_list.htm?currPage=${index_up}&type=${clientImp.type}&state=${clientImp.state}&color=${clientImp.color}&st_type=${clientImp.st_type}&stat=${state1}&stardate=${stardate}&enddate=${enddate}&haiQx=${haiQx}">${index_up}</a></li>  
	           	</#if>
	           	</#list>
				<li>...</li>
	           	<li><a href="${contextPath}/network/sczy_allot_list.htm?currPage=${pagetotal}&type=${clientImp.type}&state=${clientImp.state}&color=${clientImp.color}&st_type=${clientImp.st_type}&stat=${state1}&stardate=${stardate}&enddate=${enddate}&haiQx=${haiQx}">${pagetotal}</a></li>   
			<#else>
				<li><a href="${contextPath}/network/sczy_allot_list.htm?currPage=1&type=${clientImp.type}&state=${clientImp.state}&color=${clientImp.color}&st_type=${clientImp.st_type}&stat=${state1}&stardate=${stardate}&enddate=${enddate}&haiQx=${haiQx}">1</a></li> 
				<li>...</li>
				<#list pagetotal-8..pagetotal as index_up>  
	           	<#if currpage==index_up >  
	             <li class="current">${index_up}</li>
	           	<#else>  
	               <li><a href="${contextPath}/network/sczy_allot_list.htm?currPage=${index_up}&type=${clientImp.type}&state=${clientImp.state}&color=${clientImp.color}&st_type=${clientImp.st_type}&stat=${state1}&stardate=${stardate}&enddate=${enddate}&haiQx=${haiQx}">${index_up}</a></li> 
	           	</#if>
				</#list>  
			</#if>
			
		</#if> 
		<#if currpage==pagetotal >
		 	<li class="previous-off">下一页</li>
		<#else>
			<li class="previous"><a href="${contextPath}/network/sczy_allot_list.htm?currPage=${currpage+1}&type=${clientImp.type}&state=${clientImp.state}&color=${clientImp.color}&st_type=${clientImp.st_type}&stat=${state1}&stardate=${stardate}&enddate=${enddate}&haiQx=${haiQx}">下一页</a></li>
		</#if>
		<li class="pageinfo">共${page.total}条记录</li>
	</#if>
	</ul>
	</div>
	<div class="emptyline"></div>
	
</body>
</html>